package org.goldfish.demo011;

public class HTMLGenerator {
    String title;
    StringBuffer buffer;
    public HTMLGenerator(String title) {
        this.title = title;
        buffer = new StringBuffer();
        buffer.append("<html>");
        buffer.append("<head>");
        buffer.append("<title>").append(title).append("</title>");
        buffer.append("</head>");
        buffer.append("<body>");
    }
    public void addLink(String text,String href) {
        buffer.append("<a href=\"").append(href).append("\">").append(text).append("</a>");
    }
    public void addOrderedList(String[] list){
        buffer.append("<ul>");
        for (String s : list) {
            buffer.append("<li>");
            buffer.append(s);
            buffer.append("</li>");
        }
        buffer.append("</ul>");
    }
    public StringBuffer get(){
        return buffer.append("</body>");
    }
}
